package spe.model.spem;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;


public class MethodContentPackageImpl extends NodeElementImpl implements MethodContentPackage 
{
	protected List<MethodContentPackageableElement> ownedMembers = new ArrayList<MethodContentPackageableElement>();
	
	public List<MethodContentPackageableElement> getOwnedMembers()
	{
		return ownedMembers;
	}
	
	public void setOwnedMembers(List<MethodContentPackageableElement> members)
	{
		this.ownedMembers = members;
		
		//Need notify here
	}

	@Override
	public void addChildElement(SPEMElement child) 
	{
		if(!(child instanceof MethodContentPackageableElement))
			return;
		
		MethodContentPackageableElement mcpe = (MethodContentPackageableElement)child;
		
		ownedMembers.add((MethodContentPackageableElement)child);
			
		firePropertyChange("MethodContentPackageableElement", null, child);
		
	}

	@Override
	public void removeChildElement(MethodContentPackageableElement child) 
	{
		ownedMembers.remove(child);
		
		firePropertyChange("MethodContentPackageableElement", child, null);
	}

	@Override
	public void initialize() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<SPEMElement> getChildElements()
	{
		// TODO Auto-generated method stub
		return (new ArrayList<SPEMElement>(ownedMembers));
	}
	
	@Override
	public void addPropertyChangeListener(PropertyChangeListener listener) 
	{
		propertyChangeSupport.addPropertyChangeListener(listener);
		
		List<SPEMElement> lst = getChildElements();
		for(SPEMElement e: lst)
			e.addPropertyChangeListener(listener);
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removeChildElement(SPEMElement child) {
		// TODO Auto-generated method stub
		
	}
}
